﻿<%@ Page Title="" Language="C#" MasterPageFile="~/uc/MemberIndex.Master" AutoEventWireup="true" CodeBehind="settings.aspx.cs" Inherits="ncp.Web.member.settings" %>
<asp:Content ID="Content1" ContentPlaceHolderID="header" runat="server">
<title>用户设置-中国农业信息化服务商</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="bh-con-right-h-yy"><a href="#">信息管理</a> > 设置</div>
<div class="mod-content">
    <table>
        <tr>
            <td class="mod-label">用户帐号</td>
            <td><span id="userCode"></span></td>
        </tr>
        <tr>
            <td class="mod-label">用户名称</td>
            <td><input type="text" class="bh-input-long" id="username" maxlength="50"/><span class="msg"></span></td>
        </tr>
        <tr>
            <td class="mod-label">用户密码</td>
            <td><input type="password" class="bh-input-long" id="pwd" maxlength="50"/><span class="msg"></span></td>
        </tr>
        <tr>
            <td class="mod-label">重复密码</td>
            <td><input type="password" class="bh-input-long" id="repwd" maxlength="50"/><span class="msg"></span></td>
        </tr>
        <tr>
            <td class="mod-label">用户邮箱</td>
            <td><input type="text" class="bh-input-long" id="email" maxlength="50"/><span class="msg"></span></td>
        </tr>
        <tr>
            <td class="mod-label">手机</td>
            <td><input type="text" class="bh-input-long" id="cellphone" maxlength="50"/></td>
        </tr>
        <tr>
            <td class="mod-label">固定电话</td>
            <td><input type="text" class="bh-input-long" id="telephone" maxlength="50"/></td>
        </tr>
        <tr>
            <td class="mod-label">联系人</td>
            <td><input type="text" class="bh-input-long" id="contact" maxlength="50"/></td>
        </tr>
        <tr>
            <td class="mod-label">公司网址</td>
            <td><input type="text" class="bh-input-long" id="compweb" maxlength="50"/></td>
        </tr>
        <tr>
            <td class="mod-label">公司地址</td>
            <td><input type="text" class="bh-input-long" id="compaddr" maxlength="50"/></td>
        </tr>
        <tr>
            <td class="mod-label">QQ</td>
            <td><input type="text" class="bh-input-long" id="qq" maxlength="20"/></td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center;border-bottom: none;">
                <input type="button" class="bh-lr-btn" onclick="onSaveUserInfo()" value="保 存"/>
            </td>
        </tr>
        <tr style="border: none;">
            <td colspan="2" style="border: none;">
                备注：<br/>
                1、不修改密码请将密码栏留空<br />
                2、请填写您常用的邮箱，方便找回密码
            </td>
        </tr>
    </table>
    <script type="text/javascript">
        function loadUserInfo() {
            var response = ncp.Web.member.settings.GetUserInfo();
            if (response.value!=null) {
                var jsonOBJ = eval(response.value)[0];
                if (jsonOBJ.isreload) {
                    $("#userCode").text(jsonOBJ.account);
                    $("#username").val(jsonOBJ.username);
                    $("#email").val(jsonOBJ.email);
                    $("#cellphone").val(jsonOBJ.cellphone);
                    $("#telephone").val(jsonOBJ.telphone);
                    $("#contact").val(jsonOBJ.contact);
                    $("#compweb").val(jsonOBJ.url);
                    $("#compaddr").val(jsonOBJ.address);
                    $("#qq").val(jsonOBJ.qq);
                } else
                    alert(jsonOBJ.msg);
            }
        }
        function onSaveUserInfo() {
        	$("span.msg").text("");
            var ele = new Object();
            ele.username = $("#username").val();
            ele.pwd = $("#pwd").val();
            ele.repwd = $("#repwd").val();
            ele.email = $("#email").val();
            ele.cellphone = $("#cellphone").val();
            ele.telephone = $("#telephone").val();
            ele.contact = $("#contact").val();
            ele.compweb = $("#compweb").val();
            ele.compaddr = $("#compaddr").val();
            ele.qq = $("#qq").val();
        	if (ele.pwd!=""&&(ele.pwd!=ele.repwd)) {
                $("#pwd").next("span.msg").text("两次输入密码不一致！");
                return;
            }
            if (ele.email!=""&& (!isEmail(ele.email))) {
                $("#email").next("span.msg").text("邮箱地址不合法！");
                return;
            }
            if ((!isEmpty(ele.pwd))&&(ele.pwd!=ele.repwd)) {
                $("#pwd").next("span.msg").text("两次输入密码不一致！");
                return;
            }
            var response = ncp.Web.member.settings.SaveUserInfo($.objectToJson(ele));
            if (response.value != null) {
                var jsonOBJ = eval(response.value)[0];
                alert(jsonOBJ.msg);
            	userStatues();
            	$("#pwd,#repwd").val("");
            }
        }
        $(function() {
            loadUserInfo();
        });
    </script>
</div>
</asp:Content>
